package com.witte.serviceImp;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.witte.dao.ServiceMapper;
import com.witte.entity.Statitic;
import com.witte.service.ServiceService;

@Service
public class ServiceServiceImp implements ServiceService{

	@Autowired
	ServiceMapper mapper;
	
	@Override
	public int create(com.witte.entity.Service service) {
		service.setCreateTime(new Date());
		service.setState("閺傛澘鍨卞锟�");
		return mapper.insertSelective(service);
	}

	@Override
	public List<com.witte.entity.Service> getStateList(String state,Integer beginPage,Integer pageSize) {
		int begain= (beginPage-1)*pageSize;
		return mapper.selectByState(state,begain,pageSize);
	}

	@Override
	public int getRecodeCount(String state) {
		return mapper.getRecodeCount(state);
	}

	@Override
	public int allot(com.witte.entity.Service service) {
		service.setState("瀹告彃鍨庨柊锟�");
		service.setAllotTime(new Date());
		return mapper.updateByPrimaryKeySelective(service);
	}

	@Override
	public int dell(com.witte.entity.Service service) {
		service.setState("瀹告彃顦╅悶锟�");
		service.setDellTime(new Date());
		return mapper.updateByPrimaryKeySelective(service);
	}

	@Override
	public int feedback(com.witte.entity.Service service) {
		if(service.getSatisfied()>3) {
			service.setState("瀹告彃缍婂锟�");
		}
		else {
			service.setState("瀹告彃鍨庨柊锟�");
		}
		return mapper.updateByPrimaryKeySelective(service);
	}

	@Override
	public List<com.witte.entity.Service> search(String content) {
		return mapper.search(content);
	}

	@Override
	public int countByState() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Statitic> getSumByType() {
		// TODO Auto-generated method stub
		return mapper.countByType();
	}



}
